<template>
	<div class="login_container">
		<div class="login">
			<img src="../../../static/images/lo.jpg" style="width:120rpx;height:120rpx;" alt="">
		</div>
		<div class="login_input">
			<div class="phone_input">
				<input type="text" placeholder="请输入您的手机号" placeholder-style="font-size:25rpx;padding-left:20rpx;letter-spacing:5rpx;" v-model="input" @input="colorChange">
				<img src="../../../static/images/X.png" alt="" style="width:16px;height:16px;" v-show="inputShow" @click="deleteInput()">
			</div>
		</div>
		<div class="btn">
			<button v-bind:class="{ active: isActive, 'text-danger': hasError }" @click="btn_">下一步</button>
		</div>
	</div>
</template>

<script>
import {RegExpr} from '@/utils/regex'
export default {
	data() {
		return {
			inputShow: false,
			input: '',
			isActive: true,
			hasError: '',
		}
	},
	onLoad(options) {
	},
	computed: {
		inputImg() {
			if (this.input != '') {
				this.inputShow = true
			} else {
				this.inputShow = false
			}
		},
	},
	methods: {
		colorChange() {
			let input = RegExpr.checkMobile(this.input)
			if (input == true) {
				this.isActive = false
				this.hasError = true
			}
		},
		deleteInput() {
			this.input = ''
		},
		checkPhone() {
			let input = RegExpr.checkMobile(this.input)
			if (input == false) {
				wx.showToast({
					title: '手机格式有误',
					image: '../../static/images/gantanhao.png',
				})
			} else {
				this.$store.state.user.phone = this.input
				this.input = ''
										
					wx.navigateTo({

						url: '/pages/bindPhone/main',
					})
				
			}
		},
		btn_() {
			this.checkPhone()
		},
	},
}
</script>

<style lang="scss" scoped>
.login_container {
	background: #fff;
	width: 100%;
	height: 500px;

	.login {
		height: 250rpx;
		line-height: 380rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.login_input {
		width: 100%;
		.phone_input {
			position: relative;
			width: 90%;
			height: 80rpx;
			margin: auto;
			border-radius: 10rpx;
			img {
				position: absolute;
				right: 3%;
				bottom: 23%;
				z-index: 1000;
			}
			input {
				height: 80rpx;
				font-size: 25rpx;
				border: 1px solid #ccc;
				border-radius: 10rpx;
				padding-left: 20rpx;
			}
		}
	}
	.btn {
		width: 90%;
		margin: auto;
		margin-top: 50px;
		.active {
			background: #c4c4c4;
		}
		.text-danger {
			background: #ffd161;
		}
		button {
			margin: 0;
			padding: 0;
			outline: none;
			color: #fff;
		}
	}
}
</style>
<style>
page {
	background: #fff;
}
</style>


